/*
 * \brief  Pistachio-specific part of Genode server framework
 * \author Julian Stecklina
 * \date   2008-01-28
 */

/*
 * Copyright (C) 2008-2009 Julian Stecklina
 * Genode Labs, Feske & Helmuth Systementwicklung GbR
 *
 * This file is part of the Genode OS framework, which is distributed
 * under the terms of the GNU General Public License version 2.
 */

#include <base/server.h>

using namespace Genode;


/***********************
 ** Server entrypoint **
 ***********************/

Capability Server_entrypoint::manage(Server_object *obj)
{
	/* return invalid capability if no activation is present */
	if (!_activation) {
		PWRN("No activation present.");
		return Capability();
	}

	Capability ep_cap = Capability(_activation->cap().tid(), 0);

	if (!ep_cap.valid())
		PERR("ep_cap not valid.");

	Capability new_obj_cap = _cap_session->alloc(ep_cap);

	if (!new_obj_cap.valid())
		PWRN("new_obj_cap not valid.");

	/* add server object to object pool */
	obj->cap(new_obj_cap);
	insert(obj);

	/* return capability that uses the object id as badge */
	return new_obj_cap;
};
